<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .div1 {
      width: 100px;
      height: 100px;
      background-color: red;
    }

    .div2 {
      width: 150px;
      height: 150px;
      background-color: blue;
      position: relative;
    }

    /* 6个相对固定的class名字 */
    /* 前三个是从隐藏到显示的过程 */
    .v-enter {
      opacity: 0;
    }

    .v-enter-active {
      transition: opacity 5s;
    }

    .v-enter-to {
      opacity: 1;
    }

    /* 前三个是从显示到隐藏的过程 */
    .v-leave {
      opacity: 1;
    }

    .v-leave-active {
      transition: opacity 5s;
    }

    .v-leave-to {
      opacity: 0;
    }
    /* ==================================== */
    .zz-enter {
      left: -200px;
    }

    .zz-enter-active {
      transition: left 2s;
    }

    .zz-enter-to {
      left: 0px;
    }

    /* 前三个是从显示到隐藏的过程 */
    .zz-leave {
      left: 0px;
    }

    .zz-leave-active {
      transition: left 2s;
    }

    .zz-leave-to {
      left: -200px;
    }
  </style>
</head>

<body>
  <div id="app">
    <p>过渡效果：元素切换时，使得切换过程更流畅、自然、美观</p>
    <p>transition组件的作用是将6个class分别添加或者移除，作用于被切换的元素</p>
    <button @click="isShow = !isShow">toggle</button>
    <transition>
      <div v-show="isShow" class="div1"></div>
    </transition>
    <hr>
    <transition name="zz">
      <div v-show="isShow" class="div2"></div>
    </transition>
  </div>
  <script src="../vue.js"></script>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        isShow: true
      }
    })
  </script>
</body>

</html>